<template>
  <el-dialog
    title="修改地址"
    :visible.sync="dialogVisible"
    width="50%"
    @close="addressDialogClose"
  >
    <el-form
      :model="addressForm"
      :rules="addressFromRules"
      ref="addressFormRef"
      label-width="100px"
    >
      <el-form-item label="省市区/县" prop="address1">
        <el-cascader
          :options="cityData"
          v-model="addressForm.address1"
        ></el-cascader>
      </el-form-item>
      <el-form-item label="详细地址" prop="address2">
        <el-input v-model="addressForm.address2"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import cityData from '../citydata.js'
export default {
  data() {
    return {
      dialogVisible: false,
      addressForm: {
        address1: [],
        address2: '',
      },
      addressFromRules: {
        address1: [
          { required: true, message: '请选择省市区县', trigger: 'blur' },
        ],
        address2: [
          { required: true, message: '请填写详细地址', trigger: 'blur' },
        ],
      },
      cityData,
    }
  },
  methods: {
    addressDialogClose() {
      this.$refs.addressFormRef.resetFields()
    },
  },
}
</script>

<style>
</style>